package com.itheima.app.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private TokenInterceptor tokenInterceptor;

    @Autowired
    private FreezePublisInterceptor freezePublisInterceptor;
    @Autowired
    private FreezeSpeakInterceptor freezeSpeakInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //冻结状态拦截

        registry.addInterceptor(tokenInterceptor)//添加拦截器
                .addPathPatterns("/**")//拦截所有
                .excludePathPatterns("/user/login", "/user/loginVerification");//放行登录和验证码
        registry.addInterceptor(freezePublisInterceptor)//冻结发布动态拦截器
                .addPathPatterns("/movements");//拦截发布动态接口
        registry.addInterceptor(freezeSpeakInterceptor)//冻结发言拦截器，comments动态评论
                .addPathPatterns("/comments");

    }

}
